<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" isELIgnored="false" import="java.util.*"
	pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>报告上传</title>

<link rev="stylesheet" media="all" href="<%=request.getContextPath() %>/fare/css/form_style.css" type="text/css" rel="stylesheet">

<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/checkIE.js"></script><!--检测IE-->
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/jquery-1.6.4.min.js"></script>
 
<link href="<%=request.getContextPath() %>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath() %>/fare/lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />


<script type="text/javascript" src="<%=request.getContextPath() %>/fare/lib/ligerUI/js/ligerui.min.js"></script>

<script>

	
	
	function checkFile(){
		var filePath = document.getElementById("reportFile").value;
		var reg = /.pdf$/i;
		if (filePath.length == 0) {
			//$.ligerDialog.warn('请选择上传文件');
			alert("请选择上传文件");
			return;
		}

		// 文件格式验证
		if (!reg.test(filePath)) {
			//$.ligerDialog.warn('文件格式不正确,请上传pdf文档');
			alert('文件格式不正确,请上传pdf文档');
			return;
		}

		// 文件是否存在验证
		if (filePath <= 0) {
			$.ligerDialog.warn('上传文件不存在,请重新选择上传文件');
			alert('上传文件不存在,请重新选择上传文件');
			return;
		}
		
		if($.trim($("#miaoshu").val())==""){
			var flag=confirm("您没有输入描述，建议输入描述！\n是否继续？");
			if(!flag){return;}
		}
		
		parent.$.ligerDialog.waitting('文件上传中，请稍后...');
		var fileName = $("#reportFile").val();
		$("#fileName").val(fileName);
		//alert(fileName);
		$("#myForm").submit();
	}
	
	
	function resetForm(){
		
		$("#reportFile").val("");
		$("#miaoshu").val("");
		var date=new Date();
		//当前年份
		var year=date.getFullYear();
		//当前月份
		var month=date.getMonth()+1;
		$("#year_select").val(year);
		$("#month_select").val(month);
	}
	
	
	$(function(){
		var status = "${status}";
		if(status == "error"){
			parent.$.ligerDialog.closeWaitting();
			$.ligerDialog.warn('上传失败！请重试，或联系管理员');
		}
		if(status == "success"){
			parent.$.ligerDialog.closeWaitting();
			$.ligerDialog.success("上传成功！");
		}
		
		var date=new Date();
		//当前年份
		var year=date.getFullYear();
		//当前月份
		var month=date.getMonth()+1;
		$("#year_select").val(year);
		$("#month_select").val(month);
		
	});
	
</script>
<style type="text/css">
	
	table{
		border:2px solid #6495ED;
		
	}
	td{
		padding:4px;
	}
	
	 .btn_input{
	 	width:100px;
	 }
	
.STYLE1 {
	font-family: "新宋体";
	font-weight: bold;
}
</style>
</head>
<body >
<div align="center">
 <div class="form" align="center" style="margin-top:20px;"> 
 	<form action="<%=request.getContextPath() %>/reportUploadAction!upload.action" id="myForm" method="post" enctype="multipart/form-data">
 		<input type="hidden" name="fileName" id="fileName"/>
		<table border="0" cellpadding="0" cellspacing="0" bordercolor="#0066FF" bgcolor="#FFFFFF" >
			<tr>
				<td colspan="3" height="10">&nbsp;</td>
			</tr>
			<tr bordercolor="#00CCFF">
				<td width="120px" height="35" ><span class="STYLE1">选择上传文件:</span></td>
				<td colspan="2">
					<input name="upload" type="file" id="reportFile" size="55">
			  </td>
			</tr>
			<tr>
				<td height="34" ><span class="STYLE1">输入报告日期:</span></td>
				<td colspan="2" style="align:left">
					<select name="year" id="year_select">
     					<!-- 前后五年 -->
	 					 <c:forEach begin="<%=new Date().getYear()+1900-5%>" end="<%=new Date().getYear()+1900+5%>" var="index" >
  						 	<option value="${index}">${index }</option>
	  					 </c:forEach>      
                   </select> 年
    			
			        <select name="month" id="month_select"> 
			        	<c:forEach begin="1" end="12" var="index" >
  						 	<option value="${index }">${index }</option>
  					  </c:forEach>
			        </select> 月
				</td>
			</tr>
			
			<tr>
				<td ><span class="STYLE1">输入报告描述:</span></td>
				<td colspan="2" align="left">
					<textarea style="width:400px;height:150px" name="miaoshu" id="miaoshu"></textarea>
				</td>
			</tr>
			<tr>
				<td colspan="3" align="center">
					<input type="button" value="上 传" onclick="checkFile()" class="btn_input">
			      	<input type="button" value="重 置" onclick="resetForm()" class="btn_input">
		      	</td>
			</tr>
	  </table>
	    <div align="center"></div>
 	</form></div>	
</div>	
</form>

 
 

</body>
</html>

